//
//  Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
//  Use of this source code is subject to the terms of the Microsoft end-user
//  license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
//  If you did not accept the terms of the EULA, you are not authorized to use
//  this source code. For a copy of the EULA, please see the LICENSE.RTF on your
//  install media.
//
//------------------------------------------------------------------------------
//
//  File:  printk.c
//
//  Provide simple terminal like debug output on all terminals
//

#include <windows.h>
#include <bsp.h>
#include <bsp_oaldisp.h>
//#include <bsp_oalkeys.h>


//------------------------------------------------------------------------------
//
//  Function:  WriteDebugString
//
//  Output unicode string to terms
//
static VOID WriteDebugString(UINT16 *string)
{
	UINT8 ch;
	while (*string != L'\0')
	{
		ch = (UINT8) * string++;
		//output to LCD
		//LCDWriteByte(ch);
		//output to serial
		OEMWriteDebugByte( ch );
	}
}

//------------------------------------------------------------------------------
// Fuction:  printk
//
// print to all terminals(LCD&serial)
//
void printk(LPCWSTR format, ...)
{
	va_list pArgList;
	WCHAR buffer[128];

	va_start(pArgList, format);
	NKwvsprintfW(buffer, format, pArgList, 128);
	va_end(pArgList);
	WriteDebugString(buffer);
#ifndef EBOOT_NO_LCD	
	LCDWriteString(buffer);
#endif
}

//------------------------------------------------------------------------------
//
//  Function:  printvk
//
//  Output formatted unicode string to terms
//
VOID printvk(LPCWSTR format, va_list pArgList)
{
	WCHAR buffer[128];

	NKwvsprintfW(buffer, format, pArgList, 128);
	WriteDebugString(buffer);
#ifndef EBOOT_NO_LCD	
	LCDWriteString(buffer);
#endif
}


